package com.ml.mall.mapper.company;

import com.ml.mall.bean.vo.sys.SysUserCompanyRelationVo;
import com.ml.mall.entity.company.SysUserCompanyRelation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author pl
* Created 2021-06-15
*/
@Mapper
@Repository
public interface SysUserCompanyRelationMapper extends BaseMapper<SysUserCompanyRelation> {

    /**
     * 查询sys_user中的信息用以存储
     */
    SysUserCompanyRelationVo selectUserAndCompanyToSave(@Param("companyId") long companyId,@Param("acc") String acc);


    /**
     * 根据companyId获取用户数
     * @param companyId
     * @return
     */
    @Select("select count(1) from sys_user_company_relation where company_id = #{companyId}")
    Integer countByCompanyId(@Param("companyId") Long companyId);

    /**
     * 根据账号查询公司关联信息
     * @param acc
     * @return
     */
    List<SysUserCompanyRelation> selectByAcc(@Param("acc") String acc);
}
